
import { combineReducers } from 'redux'
import {NAME_ACTION,MEN_NAME_ACTION,WOMEN_NAME_ACTION,} from "../actions/index"
import {findConstellation} from "@/assets/utils/utils"
const d=new Date();
const constellationName=findConstellation(d.getMonth()+1,d.getDate());
export function reducer_name(state,action){
    switch (action.type) {
        case NAME_ACTION:
            localStorage.setItem(NAME_ACTION,action.text);
            return action.text
        default:
            console.log(NAME_ACTION);
            console.log( localStorage.getItem(NAME_ACTION)||constellationName);
            return localStorage.getItem(NAME_ACTION)||constellationName;
    }
}
export function reducer_men_name(state=constellationName,action){
    switch (action.type) {
        case MEN_NAME_ACTION:
            localStorage.setItem(MEN_NAME_ACTION,action.text);
            return action.text
        default:
            return localStorage.getItem(MEN_NAME_ACTION)||constellationName;
    }
}
export function reducer_women_name(state=constellationName,action){
    switch (action.type) {
        case WOMEN_NAME_ACTION:
            localStorage.setItem(WOMEN_NAME_ACTION,action.text);
            return action.text
        default:
            return localStorage.getItem(WOMEN_NAME_ACTION)||constellationName;
    }
}

export default combineReducers({
    reducer_name,
    reducer_men_name,
    reducer_women_name
})